from pythagoras import triple_gen

def solution():
    limit = 2000 * 1000
    #limit = 100
    d = dict()
    
    for t in triple_gen(limit + 1):
        s = sum(t)
        for sn in xrange(s, limit + 1, s):
            d[sn] = d.get(sn, 0) + 1
        
    print sum(1 for s in d.itervalues() if s == 1)

from timeit import Timer
print Timer('solution()', 'from __main__ import solution').timeit(1)
